var queryConditions = {};
var url = rootPath + "/crm/integralHistory";
var gridQryUrl = url + "/dataGrid.json";

var THISPAGE = {
	init : function() {
		
		this.initDom();
		this.loadGrid();
		this.addEvent();
		
	},
	initDom : function() {
	},
	loadGrid : function() {
		function t(t, e, i) {
			
			var a = '<div class="operating" data-id="'+ i.id + '"><span class="fa fa-eye mrb" title="查看"></span><span class="ui-icon ui-icon-pencil" title="修改"></span><span class="ui-icon fa-trash-o" title="删除"></span></div>';
			return a;
		}
		
		var i = Public.setGrid();
		$( "#grid" ).jqGrid({
			url : gridQryUrl,
			postData : queryConditions,
			datatype : "json",
			mtype:'POST',
			autowidth : true,
			height : i.h,
			altRows : true,
			gridview : true,
			rownumbers:true,
			multiselect : true,
			multiboxonly : true,
			colModel : [ {
				name : "name",
				label : "名称",
				align : "center",
				width:100,
				title : false
			} ],
			cmTemplate : {
				sortable : false,
				title : false
			},
			page : 1,
			sortname : "",
			sortorder : "",
			pager : "#page",
			rowNum : 50,
			rowList : [ 50,100, 200 ],
			viewrecords : true,
			shrinkToFit : false,
			forceFit : false,
			jsonReader : {
				root : "data.list",
				records : "data.totalRow",
				repeatitems : false,
				id : "id"
			},
			loadError : function() {
				parent.Public.tips({
					type : 1,
					content :"加载数据异常！"
				})
			},
			ondblClickRow : function(t) {
				$( "#" + t ).find( ".fa-eye" ).trigger( "click" );
			}
		})
	},
	reloadData : function(t) {
		
		$( "#grid" ).jqGrid("setGridParam", {
			url : gridQryUrl,
			datatype : "json",
			mtype:'POST',
			postData : t
		}).trigger( "reloadGrid" );
	},
	addEvent : function() {
		
		Public.dateCheck();
		var t = this;
		
		$( ".grid-wrap" ).on("click", ".fa-eye", function(t) {
			
			t.preventDefault();
			
			var e = $( this ).parent().data( "id" );
			THISPAGE.view( e );
			
		});
		
		$( window ).resize(function() {
			Public.resizeGrid();
		})
	}
};

THISPAGE.init();